import { BaseEntity } from "src/common/entity/BaseEntity";
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { User } from "../user/user.entity";

@Entity("article", { comment: "博文表" })
export class Article extends BaseEntity {
  // 发布用户
  @ManyToOne((type) => User, (users) => users.id)
  @JoinColumn({ name: "user_id" })
  user: string;

  // 博文标题
  @Column({ comment: "博文标题" })
  title: string;

  // 博文描述
  @Column({ comment: "博文描述" })
  description: string;

  // 博文内容
  @Column({ type: "text", comment: "博文内容" })
  content: string;

  // 点赞数
  @Column({ default: 0, name: "like_count", comment: "点赞数" })
  likeCount: number;

  // 评论数
  @Column({ default: 0, name: "comment_count", comment: "评论数" })
  commentCount: number;

  // 游览量
  @Column({ default: 0, name: "visit_count", comment: "游览量" })
  visitCount: number;
}
